<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.dao.RoleDetailsDAO"%>
<%@page import="iwpl.project.entities.RoleDetails"%>
<%@page import="javax.management.relation.Role"%>
<%@page import="iwpl.project.entities.Roles"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//String t = (String)session.getAttribute("Manage_RoleDetails");
//if(t!="active")
	//{response.sendRedirect("index.jsp");}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<center>
	<script type="text/javascript">
			function Confirm(id) 
			{
				var text = confirm("Are you sure ?");
				
				if (text == true)
				{
					//alert("Okey, Deleted !!!");
					location.href = "./servlet/Control_RoleDetail?id="+id+"&action=Delete";
				}
				else 
				{
					alert("What ever !!!");
				}
			}
		</script>
	<html>
		<head>
			<base href="<%=basePath%>">

			<title>Manage RoleDetails</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
			<style type="text/css">
.style1 {
	width: 100%;
	height: 142px;
}

.style2 {
	width: 55px;
}
</style>
		</head>

		<body>
			<form name="frmManageRoleDatail"
				action="./servlet/Control_RoleDetail" method="get">
				<table cellpadding="0" cellspacing="0">
					<tr>
						<td>



							<table align="center">
								<tr>
									<td colspan="3" align="center">
										Manage RoleDetails 
										<br>
									</td>
								</tr>
								<tr>
									<td>
										<a href="Insert_RoleDetails.jsp">Insert</a>
									</td>
									<td colspan="2">
										<label>
											
										</label>
									</td>

								</tr>

								<tr>
									<td colspan="3">
										<%
								Integer id = 0;
								if(request.getParameter("rold")!=null)
								id = Integer.parseInt(request.getParameter("rold"));
								RoleDetailsDAO rol = new RoleDetailsDAO();
								List<RoleDetails> data = null;
								if(id!=0)
								{
									Roles s = new Roles();
									s.setId(id);
									data = rol.findByProperty("roles",s);
								}
								else
								{
									data = rol.findAll();
								} 
								
								//String rid = data.getRoles().getRoleName();
							
							
							%>
										<table>
											<tr bgcolor="5f9ff5">
											<td>
												No.
											</td>
												<td>
													Role Name
												</td>
												<td>
													FormName
												</td>
												<td>
													Ins
												</td>
												<td>
													Del
												</td>
												<td>
													Upd
												</td>
												<td>
													View
												</td>
												<td>
													All
												</td>
												<td>
													Edit
												</td>
												<td>
													Delete
												</td>
											</tr>
											<tr>
												
												<%
												int i =0;
												String insert="unactive";
												String update="unactive";
												String delte="unactive";
												String view="unactive";
												String all="unactive";
												
												for (Iterator<RoleDetails> it = data.iterator(); it.hasNext();) {
														RoleDetails acc = (RoleDetails) it.next();
													i++;
							
														if (i % 2 != 0) {
															out.println("<tr bgcolor=\"#CCFFFF\"><td>");
														} else {
															out.println("<tr bgcolor=\"#99CCCC\"><td>");
														}
													out.println(i + "</td>");
													out.println("<td>" + acc.getRoles().getRoleName()+"</td>");
													out.println("<td>" + acc.getForms().getFormsName() + "</td>");
													out.println("<td>" + acc.getIns().toString() + "</td>");
													out.println("<td>" + acc.getDel().toString() + "</td>");
													out.println("<td>" + acc.getUpd().toString() + "</td>");
													out.println("<td>" + acc.getVie().toString() + "</td>");
													out.println("<td>" + acc.getAl().toString() + "</td>");
													
													out.println("<td><a href="
														+ "/DepartmentManage/Update_RoleDetails.jsp?fid="
														+ acc.getId().toString() + " /><img src="
														+ "./images/Edit.jpg" + " /></td>");
													
													out.println("<td><a href=javascript:Confirm('" + acc.getId()
														+ "') /><img src=" + "./images/Delete.jpg"
														+ " /></td>");
													
													
													}
												 %>
												
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</form>
		</body>
	</html>
</center>